<template>
    <div>
      <form action="">
        <input type="text" v-model="username">用户名
        <button @click="on_submit">提交</button>
      </form>
    </div>
</template>

<script>
  import axios from 'axios'
    export default {
        name: "register",
        data(){
          return{
            username:''
          }
        },
        methods:{
          on_submit(){
            axios({
              url:'http://127.0.0.1:8000/register/',
              method:'post',
              data:{'username':this.username}
            }).then(res=>{
              if(res.data.code==200){
                localStorage.setItem('name',res.data.uid)
                this.$router.push('/show')
              }
              else {
                alert('登录失败')
              }
            })
          }
        }
    }
</script>

<style scoped>

</style>
